<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EnclosedAdmin
 *
 * @author agama
 */
class EnclosedAdmin extends EnclosedAttach
{

    function __construct()
    {
        parent::__construct();

        $this->deletable = true;
        $this->levelable = true;
    }

    function doPOST( Event $e )
    {
        if ( $e->tag == 'change_level' ) {
            if ( $this->leveleable ) { //de hecho aqui siempre lo es
                //$nivel=(int)$_POST['privacy'];//0: public, 1:enterprise, 2:private
                if ( $_POST[ 'privacy' ] == 'R_PUB_PRO' ) {
                    if ( $this->resource_enclosed != 'R_PUB_PRO' ) {
                        //lo cambio a publico
                        //si solo permito cambiar privacidad
                        $sql = 'UPDATE enclosed SET privacy_enclosed=\'R_PUB_PRO\' WHERE id=' . $this->id;
                        MyLink::$default->execute( $sql );

                        $this->notifyOwner( 'PRIVACY' );
                    }
                } else if ( $_POST[ 'privacy' ] == 'R_ENT_PRO' ) {
                    if ( $this->resource_enclosed != 'R_ENT_PRO' ) {
                        //lo cambio a publico

                        $sql = 'UPDATE enclosed SET privacy_enclosed=\'R_ENT_PRO\' WHERE id=' . $this->id;
                        MyLink::$default->execute( $sql );

                        $this->notifyOwner( 'PRIVACY' );
                    }
                } else if ( $_POST[ 'privacy' ] == 'R_PRV_PRO' ) {
                    if ( $this->resource_enclosed != 'R_PRV_PRO' ) { //visibilidad
                        $sql = 'UPDATE enclosed SET privacy_enclosed=\'R_PRV_PRO\' WHERE id=' . $this->id;
                        MyLink::$default->execute( $sql );

                        $this->notifyOwner( 'PRIVACY' );
                    }
                }
            }

            $e->cancelBubble();
        }
        else parent::doPOST( $e );
    }

}

?>
